//
//  KYMatchDoctorViewController.m
//  kuaiyi
//
//  Created by 杨亮 on 16/3/16.
//  Copyright © 2016年 kuaiyi. All rights reserved.
//

#import "KYMatchDoctorViewController.h"
#import "KYMatchDorctorModel.h"
#import "KYMatchDoctorTableViewCell.h"
#import "KYDoctorViewController.h"


@interface KYMatchDoctorViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic, strong)NSMutableArray *modelList;
@end
static NSString *ID = @"KYMatchDoctorTableViewCell";
@implementation KYMatchDoctorViewController
-(NSMutableArray *)modelList{
    if (!_modelList) {
        _modelList = [NSMutableArray array];
    }
    return _modelList;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self setUpUI];
}
-(void)setUpUI{
    UITableView *table = [[UITableView alloc]init];
    self.view = table;
    table.delegate = self;
    table.dataSource = self;
    table.rowHeight = 80;
//    [table registerNib:[UINib nibWithNibName:@"KYMatchDoctorCell" bundle:nil] forCellReuseIdentifier:ID];
    __weak typeof(self) weakSelf = self;
    [KYMatchDorctorModel getMatchDorctorModelSuccess:^(NSMutableArray *dorctorModel) {
        weakSelf.modelList = dorctorModel;
        [table reloadData];
    }];

}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.modelList.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    KYMatchDoctorTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        cell = [KYMatchDoctorTableViewCell getCell];
//        cell = [[[NSBundle mainBundle]loadNibNamed:@"KYMatchDoctorCell" owner:nil options:0]lastObject];
    }
    KYMatchDorctorModel *model = self.modelList[indexPath.row];
    cell.model = model;
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    KYDoctorViewController *doctorVC = [[KYDoctorViewController alloc]init];
    [self.navigationController pushViewController:doctorVC animated:YES];
    doctorVC.title = @"医生基本信息";
    doctorVC.matchDorctorModel = self.modelList[indexPath.row];
    
}
@end
